package com.zhike.b2b.market.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import com.zhike.b2b.base.BaseService; 
import com.zhike.b2b.market.IMarketService;
import com.zhike.b2b.model.MarketVo;

@Service
public class MarketService extends BaseService implements IMarketService {
	/**
	 * 获取最新价格列表
	 * @return
	 */
	public List<MarketVo> getPriceList()
	{
		String sql = " select market_name,class_id,oper_time,money,moneytype,unit from market order by oper_time desc "; 
		List<MarketVo> lmc = jt.query(sql.toString(), new RowMapper<MarketVo>() {
			public MarketVo mapRow(ResultSet rs, int rowNum) throws SQLException {
				MarketVo mv = new MarketVo();
				mv.setName(rs.getString("market_name"));
				mv.setClassId(rs.getString("class_id"));
				mv.setOperTime(rs.getString("oper_time"));
				mv.setMoney(rs.getString("money"));
				mv.setMoneytype(rs.getString("moneytype"));
				String unit = rs.getString("unit");
				unit = ps.getDataParam("product_unit", unit);
				mv.setUnit(unit);
				return mv;
			}
		});
		return lmc;
	}

}
